package com.daichi.controller;


import com.daichi.common.lang.Result;
import com.daichi.controller.base.BaseController;
import com.daichi.entity.User;
import com.daichi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Daichi Chou
 * @since 2021-05-27
 */
@RestController
@RequestMapping("/user")
public class UserController extends BaseController {

    private final UserService userService;

    @Autowired
    public UserController(UserService userService) {
        this.userService = userService;
    }

    @GetMapping("getUser")
    public User getUser() {
        return userService.getById(1);
    }

    @PostMapping("/save")
    public Result save(@RequestBody @Validated User user) {
        return Result.succ(user);
    }

}
